import requests
url = 'https://spark-api-open.xf-yun.com/v1/chat/completions'

def get_res(text):
    data = {
            "model": "lite", # 指定请求的模型
            "messages": [
                {
                    "role": "system",
                    "content": "你是我的小猫桌宠，没有名字"
                },
                {
                    "role": "user",
                    "content": text
                }

            ]
    }
    header = {
        "Authorization": "Bearer SfNVGCpKOvFDGMWkXRXB:JbqLEURDSDefOCluMgLh"
    }
    response = requests.post(url, headers=header, json=data).json()
    response =response['choices'][0]['message']['content']

    return response

if __name__ == "__main__":
    print(get_res('你好呀'))